<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>添加夺宝产品</title>
    <link href="/resource/admin/css/common.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/resource/admin/js/jquery.js"></script>
    <script type="text/javascript" src="/resource/admin/js/jquery.tools.js"></script>
    <script type="text/javascript" src="/resource/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="/resource/admin/editor/kindeditor.js"></script>
    <script type="text/javascript" src="/resource/admin/js/common.js"></script>
    <script type="text/javascript" src="/resource/admin/js/input.js"></script>
    <script type="text/javascript">
        $().ready(function() {
            var $inputForm = $("#inputForm");
            [@flash_message /]

            var $productImageTable = $("#productImageTable");
            var $addProductImage = $("#addProductImage");
            var $deleteProductImage = $("a.deleteProductImage");
            var productImageIndex = 0;

            // 增加商品图片
            $addProductImage.click(function() {
            [@compress single_line = true]
                var trHtml =
                        '<tr>
                        <td>
                        <input type="file" name="productImages[' + productImageIndex + '].file" class="productImageFile" \/>
                <\/td>
            <td>
            <input type="text" name="productImages[' + productImageIndex + '].title" class="text" maxlength="200" \/>
                <\/td>
            <td>
            <input type="text" name="productImages[' + productImageIndex + '].order" class="text productImageOrder" maxlength="9" style="width: 50px;" \/>
                <\/td>
            <td>
            <a href="javascript:;" class="deleteProductImage">[${message("admin.common.delete")}]<\/a>
            <\/td>
            <\/tr>';
            [/@compress]
                $productImageTable.append(trHtml);
                productImageIndex ++;
            });

            // 删除商品图片
            $deleteProductImage.live("click", function() {
                var $this = $(this);
                $.dialog({
                    type: "warn",
                    content: "${message("admin.dialog.deleteConfirm")}",
                    onOk: function() {
                        $this.closest("tr").remove();
                    }
                });
            });
        });
    </script>
</head>
<body>
<div class="path">
    <a href="${base}/common/index">首页</a> &raquo;添加文章
</div>
<form id="inputForm" action="save" method="post" class="required-form" enctype="multipart/form-data"  onsubmit="return validateForm(this)">
    <ul id="tab" class="tab">
        <li>
            <input type="button" value="商品信息" />
        </li>
        <li>
            <input type="button" value="商品介绍" />
        </li>
        <li>
            <input type="button" value="商品图片" />
        </li>
    </ul>
    <table class="input tabContent">
        <tr>
            <th>
                商品类型
            </th>
            <td>
                <select name="dbProductTypeId" class="text">
                [#list dbProductTypeList as dbProductType]
                    <option value="${dbProductType.id}">${dbProductType.name}</option>
                [/#list]
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>SN
            </th>
            <td>
                <input type="text" name="sn" class="text required" maxlength="100" />
            </td>
        </tr>

        <tr>
            <th>
                <span class="requiredField">*</span>名称
            </th>
            <td>
                <input type="text" name="name" class="text" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>全称
            </th>
            <td>
                <input type="text" name="fullName" class="text" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>上架
            </th>
            <td>
                <select name="isMarketable" class="text">
                    <option value="0">否</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>自动上架
            </th>
            <td>
                <select name="isAutoMarketable" class="text">
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>商品来源
            </th>
            <td>
                <select name="flag" class="text">
                    <option value="0">自营</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
               排序
            </th>
            <td>
                <input type="text" name="order" value="0" class="text" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>备注
            </th>
            <td>
                <span class="fieldSet">
				    <input type="text" name="memo" class="text" maxlength="100" style="width: 500px;"/>
                    <span style="color: #cc0000;">30个汉字以内的简短描述</span>
                </span>
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <td colspan="4">
                <textarea id="editor" name="introduction" class="editor" style="width: 100%;"></textarea>
            </td>
        </tr>
    </table>
    <table class="input tabContent" id="productImageTable">
        <tr>
            <td colspan="4">
                <a href="javascript:;" id="addProductImage" class="button">添加</a>
            </td>
        </tr>
        <tr class="title">
            <td>
                文件
            </td>
            <td>
                标题
            </td>
            <td>
                排序
            </td>
            <td>
                删除
            </td>
        </tr>
    </table>
    <table class="input">
        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" class="button" value="提交" />
                <input type="button" class="button" value="返回" onclick="location.href='list'" />
            </td>
        </tr>
    </table>
</form>
</body>
</html>